PIC 16x84 Basics

[Home] [Introducing PIC] [Microcontrollers] [Animated Tutorials] [Webseminars]

Free PIC Microcontroller Books!

Google

Web

This Site

Indirect Addressing; INDF and FSR Registers

 

INDF Register

The INDF register is not a physical register. Addressing INDF actually addresses the register whose address is contained in the FSR register (FSR is a pointer). This is indirect addressing.

  • Register file 05 contains the value 10h
  • Register file 06 contains the value 0Ah
  • Load the value 05 into the FSR register
  • A read of the INDF register will return the value of 10h
  • Increment the value of the FSR register by one (FSR = 06)
  • A read of the INDF register now will return the value of 0Ah.

Reading INDF itself indirectly (FSR = 0) will produce 00h. Writing to the INDF register indirectly results in a no-operation (although STATUS bits may be affected). A simple program to clear RAM locations 20h-2Fh using indirect addressing is shown Below:

FSR Register

File register 04 is the File Select Register (FSR). It is used for indirect or indexed addressing of the other file registers, particularly the GPRs (General Purpose Registers 0Ch-4Fh). If a file register address (00–4F) is loaded into FSR, the contents of that file register can be read or written through file register 00, the Indirect File Register (INDF). This method can be used for accessing a set of data RAM locations, by reading or writing the data via INDF, and selecting the next file register by incrementing FSR. This indexed, indirect file register addressing is particularly useful for storing a set of data which has been read in at a port, in, for example, a data logging application. An output data table of predefined values, such as seven-segment display codes, can use the program data table method described. The demonstration Program below loads a set of file registers, 20–2F, with dummy data (AA), using FSR as the index register. Here, FSR operates as a pointer to a block of locations and is incremented between each read or write operation. Notice that the data actually has to be moved into INDF each time.

     FSR EQU 04      ; File Select Register
     INDF EQU 00     ; Indirect File Register
     movlw 020       ; First GPR = 20h
     movwf FSR       ; to FSR ---> 1,2
     movlw 0AA       ; Dummy data --->3
NEXT movwf INDF      ; to INDF and GPRxx --->4
     incf FSR        ; Increment GPR Pointer ---> 1
     btfss FSR,4     ; Test for GPR = 30h
     goto next       ; if GPR is less than 30h Write next GPR
CONTINUE
   :                 ;Else, continue

Indirect File Register Addressing - Flow of the above program.